<?php 
	echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
	header("Content-type: application/xml; charset=UTF-8"); 
	include 'config.php';
?>

<feed xmlns="http://www.w3.org/2005/Atom">

<?php
	// Write out so basic rss stuff
	//2003-12-13T18:30:02Z
	$update_time = date(DATE_ATOM);
	echo "<link rel=\"self\" href=\"" . $blog_url . "joleblog/rss.php\" />\n";
	echo "<title>" . $blog_title . "</title>\n";
	echo "<link href=\"" . $blog_url . "\" />\n";
	echo "<updated>" . $update_time . "</updated>\n";
	echo "<author>\n<name>" . $blog_author . "</name>\n</author>\n";
	echo "<id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id>";

  	// load our ini
	$content = parse_ini_file($blog_db, true);
	// see how many posts we have in total
	$number_of_entries = count($content);
	// because we're going to be printing them in sequential order, we need to rekey them that way
	$rekeyment = array_keys($content);

	// write them out using their rekeys as their keys ;-)
	for ($i=0; $i<$number_of_entries; $i++)
	{
		// strip the slashes (if there are any), and html safe
		$content[$rekeyment[$i]]['title'] = htmlspecialchars(stripslashes($content[$rekeyment[$i]]['title']));
		$content[$rekeyment[$i]]['content'] = htmlspecialchars(stripslashes($content[$rekeyment[$i]]['content']));

		echo "<entry>\n";
		echo "\t<title type=\"html\">" . $content[$rekeyment[$i]]['title'] . "</title>\n";
		echo "\t<link href=\"" . $blog_url .  $blog_controller . "?post=" . $rekeyment[$i] . "\" />\n";
		$entry_update = date(DATE_ATOM, $rekeyment[$i]);
		echo "\t<updated>" . $entry_update . "</updated>\n";
		echo "\t<id>" . $blog_url .  $blog_controller . "?post=" . $rekeyment[$i] . "</id>\n";
		echo "\t<summary type=\"html\">" . $content[$rekeyment[$i]]['content'] . "</summary>\n";
		echo "</entry>";
	}
?></feed>
